Refactor OMNIBUSF4 targets into separate directories#43
Refactor OMNIBUSF4 targets into separate directories#43sensei-hacker wants to merge 31 commits intomaintenance-9.xfrom
Conversation
Adds minPowerIndex (byte 12) to MSP_VTX_CONFIG response to indicate the minimum valid power index for the VTX device. - MSP VTX: minPowerIndex = 0 (supports power off at index 0) - SmartAudio/Tramp: minPowerIndex = 1 (power off not supported) This allows configurator to correctly display all available power levels without hardcoding device-specific logic. Backward compatible: old configurators will ignore the extra byte. Related: iNavFlight/inav-configurator#2486 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||||||||
Split OMNIBUSF4 mega-target into 4 directories to improve maintainability: - DYSF4: DYSF4PRO, DYSF4PROV2 - OMNIBUSF4: Base OMNIBUSF4 variant only - OMNIBUSF4PRO: OMNIBUSF4PRO, OMNIBUSF4V3, OMNIBUSF4V3_ICM - OMNIBUSF4V3_SS: Softserial variants (S6_SS, S5S6_SS, S5_S6_2SS) Each directory now contains only the code relevant to its variants, with irrelevant preprocessor conditionals removed. Changes: - Reduced DYSF4/target.h from 271 to 169 lines (37% reduction) - Reduced preprocessor conditionals from 18 to 4 in DYSF4 files - All 11 targets build successfully and produce identical binaries
e61568d to
cebc906
Compare
Remove preprocessor conditionals that can never be true in split directories: - OMNIBUSF4PRO: Remove checks for _S6_SS variants (in different directory) - OMNIBUSF4V3_SS: Remove checks for OMNIBUSF4PRO/V3 (in different directory) - Remove OMNIBUSF4PRO_LEDSTRIPM5 references (target no longer exists) Update comments to accurately describe what targets each directory contains. All affected targets build successfully.
The OMNIBUSF4 directory now only contains the base OMNIBUSF4 target. All other variants (OMNIBUSF4PRO, OMNIBUSF4V3, DYSF4, etc.) are in separate directories. Used unifdef to remove all conditionals for non-OMNIBUSF4 targets: - Removed checks for OMNIBUSF4PRO, OMNIBUSF4V3, DYSF4PRO, DYSF4PROV2 - Removed checks for softserial variants (_S6_SS, etc.) - Removed LEDSTRIPM5 references Results: - target.h: 280 → 147 lines (47% reduction, 133 lines removed) - target.c: cleaned (7 conditionals removed) - All conditionals removed: 0 remaining in both files - OMNIBUSF4 target builds successfully The OMNIBUSF4 directory now contains only the code specific to the base OMNIBUSF4 variant with no dead branches.
1. Added alias for OMNIBUSF4V3_ICM → OMNIBUSF4V3 in OMNIBUSF4PRO/target.h This fixes a critical bug where OMNIBUSF4V3_ICM would get wrong configuration: - Wrong IMU alignment (CW180 instead of CW270) - Missing MPU6500/BMI270 support - Wrong barometer (I2C-only instead of SPI BMP280) - Missing UART inverter support - Wrong SPI3_NSS_PIN (PB3 instead of PA15) - Wrong blackbox (SPI flash instead of SD card) - Wrong timer configuration 2. Removed dead #else clauses after OMNIBUS split: - DYSF4/target.h: Removed unreachable fallback cases - OMNIBUSF4PRO/target.h: All #else branches now dead after alias fix - OMNIBUSF4V3_SS/target.h: Removed unreachable softserial fallback All affected targets verified to build successfully.
- DYSF4/target.h: Removed ICM20608 comment (no ICM support in this directory) - OMNIBUSF4/target.h: Removed ICM20608 comment (no ICM support in this directory) - OMNIBUSF4/target.h: Removed obsolete relationship comments from consolidated file ICM20608 support only exists in OMNIBUSF4PRO and OMNIBUSF4V3_SS directories.
The #else branch at lines 44-46 was unreachable after adding OMNIBUSF4V3_ICM aliasing. All three targets (OMNIBUSF4PRO, OMNIBUSF4V3, OMNIBUSF4V3_ICM) always use TIM4/PB9, never TIM12/PB15.
1. Removed outdated 'pad labelled CH5/CH6 on OMNIBUSF4PRO' comments from: - OMNIBUSF4/target.h and target.c (wrong target) - DYSF4/target.h and target.c (wrong target) - OMNIBUSF4V3_SS/target.c (wrong target) These comments are only accurate in the OMNIBUSF4PRO directory where PC8/PC9 really are labelled CH5/CH6 on the physical board. 2. Removed redundant conditional from OMNIBUSF4PRO/target.c: #if (defined(OMNIBUSF4PRO) || defined(OMNIBUSF4V3)) This is always true since all 3 targets in this directory (OMNIBUSF4PRO, OMNIBUSF4V3, OMNIBUSF4V3_ICM) have one of these defined.
Remove orphaned indentation from preprocessor defines that were previously inside conditional blocks but are now at top level after the target split. Files changed: - OMNIBUSF4/target.h: Fixed 2-space and 4-space orphaned indents - DYSF4/target.h: Fixed 2-space orphaned indents - OMNIBUSF4V3_SS/target.h: Fixed extensive 2-space orphaned indents - OMNIBUSF4PRO/target.h: Fixed 4-space orphaned indent on ADC_CHANNEL_3_PIN Valid indentation inside active #if blocks was preserved. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The updateArmingStatus() function performs 20+ safety checks (GPS fix, battery voltage, sensor health, LED updates, etc.) that don't need millisecond-level updates. Previously called every PID loop iteration (2000 Hz), now rate-limited to 200 Hz. Testing on AT32F435 hardware showed 10-13% PID loop performance improvement with no functional impact. 200 Hz (5ms response time) is well within human reaction time (~200ms) and exceeds the update rate of the sensors being checked (GPS: 5-10 Hz, battery: slow).
The AGL velocity update was incorrectly using squared acceleration weight factor (sq(accWeightFactor)) while the altitude update uses linear weight. This creates physical inconsistency where position and velocity respond differently to the same acceleration. With accWeightFactor=0.5 (moderate confidence): - Altitude receives 50% of acceleration (correct) - Velocity was receiving 25% of acceleration (wrong - squared) This fix removes sq() from the velocity update to match the altitude update, making both integrations physically consistent with standard kinematic equations. May fix iNavFlight#10314 May be related to iNavFlight#10567
Comments incorrectly stated 0.3 when code uses 0.5f. Updated comments to match actual implementation.
These entries are not relevant to this PR and should not be included in upstream changes.
Prepare for 9.0.1 patch release.
…ersion-9.0.1 Bump firmware version to 9.0.1
…ty-weight-squared Fix AGL velocity estimation using squared acceleration weight factor
The periodic MON-VER and MON-GNSS polls in the main GPS loop waited on _ack_state for ACK/NAK. MON-class messages never produce ACK/NAK (only CFG-class messages do), so ptWaitTimeout always hit the full 500ms timeout. This blocked gpsProcessNewSolutionData from being called, causing a data processing stall every GPS_CAPA_INTERVAL (5s). Wait on actual response data instead, matching the pattern already used in the initialization code: hwVersion change for MON-VER, and lastCapaUpdMs timestamp for MON-GNSS.
The receiver thread parses MON-VER/MON-GNSS responses asynchronously. Nothing between the polls and the next loop iteration depends on the updated data, so the waits just block position fix processing for no benefit. The 5-second GPS_CAPA_INTERVAL already prevents re-polling too frequently.
The default IMU_ICM42605_ALIGN was set to CW180_DEG, which is 180 degrees off from the physical direction arrow on the RadioMaster NEXUS-X board. Users had to manually apply YAW-180 correction in the configurator to get correct orientation. Change alignment to CW0_DEG to match the board silkscreen. Fixes iNavFlight#11325
…ateArmingStatus Reduce CPU overhead by rate-limiting updateArmingStatus() to 200 Hz
…oll-stall Fix GPS capability poll blocking for 500ms every 5 seconds
…_corr_refactor Position estimator sensor correction refactor
…wer-min MSP: Add minimum power index to MSP_VTX_CONFIG
…5-nexusx-imu-orientation Fix NEXUSX default IMU orientation
The upstream added OMNIBUSF4V3_ICM support to the monolithic OMNIBUSF4/target.h. This PR moves OMNIBUSF4V3_ICM to the new OMNIBUSF4PRO/ directory alongside V3. Resolution: - OMNIBUSF4/target.h: keep PR version (base target only, no PRO/V3/ICM) - OMNIBUSF4/CMakeLists.txt: keep PR version (only OMNIBUSF4 here) - OMNIBUSF4PRO/target.h: add ICM42605 support for OMNIBUSF4V3_ICM, which was present in upstream but missing from the split target
User description
Summary
Split the OMNIBUSF4 target directory into three separate directories to reduce complexity and improve maintainability:
Changes
src/main/target/DYSF4/with target.h, target.c, CMakeLists.txtsrc/main/target/OMNIBUSF4PRO/with target.h, target.c, CMakeLists.txtsrc/main/target/OMNIBUSF4/files to remove targets moved to other directoriesVerification
All 9 targets verified to produce identical preprocessed output before and after split using
gcc -E:All 9 targets build successfully with no errors.
Benefits
PR Type
Enhancement, Bug fix
Description
This description is generated by an AI tool. It may have inaccuracies
Refactor OMNIBUSF4 target into three separate directories (DYSF4, OMNIBUSF4, OMNIBUSF4PRO) to reduce complexity and improve maintainability
Fix critical cppcheck bugs: integer overflow in fc/config.h and buffer overrun in sensors/temperature.c
Fix CRSF buffer overflow vulnerability and dashboard sizeof bug in io/dashboard.c
Add comprehensive Power and Current Limiting documentation to Battery.md with configuration examples
Update JavaScript programming documentation to use namespaced API (inav.flight, inav.override, inav.events)
Improve SD card handling with timeout protection and DMA buffer alignment for STM32H7
Add MSC USB descriptor support and improve power limiter initialization logic
Diagram Walkthrough
File Walkthrough
7 files
Remove conditional compilation for split targetsAdd timeout protection and DMA buffer alignmentAdd retry logic and operation timeout handlingAdd operation retry counter definitionUse MSC descriptor for standalone MSC modeAdd MSC-specific USB descriptor functionsExport MSC descriptor structure6 files
New target header for OMNIBUSF4PRO variantsNew timer hardware configuration for PRO variantsBuild configuration for OMNIBUSF4PRO targetsNew target header for DYS variantsNew timer hardware configuration for DYS variantsBuild configuration for DYSF4 targets5 files
Fix signed integer overflow in feature flagsFix buffer overrun in memset callFix sizeof bug with pointer to array conversionAdd bounds check for CRSF frame lengthFix burst limit validation logic for disabled state12 files
Add comprehensive power and current limiting documentationUpdate examples to use namespaced inav APIUpdate timer and whenChanged examples with inav namespaceUpdate implementation examples with inav namespaceUpdate operation examples with inav namespaceUpdate test examples with inav namespaceUpdate API maintenance guide with inav namespaceUpdate API definitions with inav namespaceUpdate constant generation guide with inav namespaceUpdate implementation summary with inav namespaceUpdate main index with inav namespace and featuresUpdate branching workflow and maintenance branch guidance2 files